<?php $this->pageTitle = Yii::app()->name; ?>

<?php
if (Yii::app()->user->isGuest) {
?>
    <div class="form">
    <?php
    $form = $this->beginWidget('CActiveForm', array(
                'id' => 'login-form',
                'enableAjaxValidation' => true,
            )); ?>

    <p class="note">Los campos con <span class="required">*</span> son obligatorios.</p>

    <div class="row">
        <?php echo $form->labelEx($model, 'username'); ?>
        <?php echo $form->textField($model, 'username'); ?>
        <?php echo $form->error($model, 'username'); ?>
    </div>

    <div class="row">
        <?php echo $form->labelEx($model, 'password'); ?>
        <?php echo $form->passwordField($model, 'password'); ?>
        <?php echo $form->error($model, 'password'); ?>
    </div>

    <div class="row rememberMe">
        <?php echo $form->checkBox($model, 'rememberMe'); ?>
        <?php echo $form->label($model, 'rememberMe'); ?>
        <?php echo $form->error($model, 'rememberMe'); ?>
    </div>

    <div class="row buttons">
        <?php echo CHtml::submitButton('Entrar'); ?>
    </div>

    <?php
        $this->endWidget();
    ?>
    </div>
<?php
    } else {
        if (Yii::app()->user->id == "admin") {
?>
            <ul>            
                <li><a href="?r=user">Administrar usuarios</a></li>
                <li><a href="?r=bar">Administrar bares</a></li>
            </ul>            
<?php
        } else {
?>
            <h2>Mis bares</h2>
            <ul>
    <?php
            foreach ($dataProvider->getData() as $bar) {
                printf("<li><a href=\"?r=bar/view&id=%s\">%s</a></li>", $bar->id, $bar->establecimiento);
            }
    ?>
        </ul>
<?php
        }
    }
?>
